package com.acwing.partition21;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/30 21:25
 */
public class AC2032过度种植 {

    private static final int N = 11, M = 20010, BASE = 10010;
    private static Node[] tr = new Node[M << 2];
    private static Segment[] seg = new Segment[N << 1];
    private static int n, m = 0;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 0; i < n; i++) {
            int x1 = nextInt() + BASE, y1 = nextInt() + BASE, x2 = nextInt() + BASE, y2 = nextInt() + BASE;
            seg[m++] = new Segment(x1, y2, y1, 1);
            seg[m++] = new Segment(x2, y2, y1, -1);
        }
        Arrays.sort(seg, 0, 2 * n);
        build(1, 0, M - 1);
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (i > 0) ans += tr[1].len * (seg[i].x - seg[i - 1].x);
            modify(1, seg[i].y1, seg[i].y2 - 1, seg[i].k);
        }
        writer.println(ans);
        writer.flush();
    }

    private static void modify(int u, int l, int r, int k) {
        if (l <= tr[u].l && r >= tr[u].r) tr[u].cnt += k;
        else {
            int mid = tr[u].l + tr[u].r >> 1;
            if (l <= mid) modify(u << 1, l, r, k);
            if (r > mid) modify(u << 1 | 1, l, r, k);
        }
        pushup(u);
    }

    private static void build(int u, int l, int r) {
        tr[u] = new Node(l, r);
        if (l != r) {
            int mid = l + r >> 1;
            build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r);
            pushup(u);
        }
    }

    private static void pushup(int u) {
        if (tr[u].cnt > 0) tr[u].len = tr[u].r - tr[u].l + 1;
        else if (tr[u].l == tr[u].r) tr[u].len = 0;
        else tr[u].len = tr[u << 1].len + tr[u << 1 | 1].len;
    }

    private static class Segment implements Comparable<Segment> {
        private int x, y1, y2, k;

        public Segment(int x, int y1, int y2, int k) {
            this.x = x;
            this.y1 = y1;
            this.y2 = y2;
            this.k = k;
        }

        @Override
        public int compareTo(Segment o) {
            return Integer.compare(x, o.x);
        }
    }

    private static class Node {
        private int l, r, cnt, len;

        public Node(int l, int r) {
            this.l = l;
            this.r = r;
        }
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
